from django.shortcuts import render
from rest_framework.generics import ListAPIView
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter
# Create your views here.


from . import models
from . import serializers
from .pagenumberpagination import CustomPageNumberPagination

class CourseCategoryAPIView(ListAPIView):
    queryset = models.CourseCategory.objects.filter(is_show=True, is_deleted=False).order_by('orders')
    serializer_class = serializers.CourseCategoryModelSerializer


class CourseListAPIView(ListAPIView):
    queryset = models.Course.objects.filter(is_show=True, is_deleted=False).order_by('orders')
    serializer_class = serializers.CourseModelSerializer
    filter_backends = [DjangoFilterBackend, OrderingFilter]
    filter_fields = ['course_category', ]
    ordering_fields = ['id','students','price']
    pagination_class = CustomPageNumberPagination
